package com.cloudlead.customerAction.action;

import com.cloudlead.common.lang.annotation.Label;
import com.cloudlead.common.lang.persistence.EasyuiGridData;
import com.cloudlead.common.lang.persistence.Page;
import com.cloudlead.common.worker.action.impl.AbstractActionFactory;
import com.cloudlead.common.worker.annotation.Action;
import com.cloudlead.common.worker.annotation.Order;
import com.cloudlead.customerAction.BusinessModules;
import com.cloudlead.customerAction.service.CustomerOrdeCreateSer;
import com.cloudlead.customerAction.service.CustomerOrdeFindSer;
import com.cloudlead.customerService.CustomerOrderCreateService;
import com.cloudlead.customerService.CustomerOrderFindService;
import com.cloudlead.customerService.vo.CreateCustmoerOrderVo;
import com.cloudlead.customerService.vo.FleetPriceVo;
import com.cloudlead.customerService.vo.ForwardPriceVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.validation.constraints.NotNull;

/**
 * Created by 123 on 2015/8/31.
 */
@Controller
public class CustomerOrderCreateActionFactory extends AbstractActionFactory implements CustomerOrderCreateService {


    public CustomerOrderCreateActionFactory() {
        super(BusinessModules.CustomerOrderCreate);
    }


    @Autowired
    CustomerOrdeCreateSer customerOrdeCreateSer;
    @Override
    @Action
    @Order(2)
    @Label("创建订单")
    public String createOrder(CreateCustmoerOrderVo vo) {
        return customerOrdeCreateSer.createOrder(vo);
    }

    @Override
    @Action
    @Order(2)
    @Label("查询航线列表")
    public EasyuiGridData findAllRoute() {
        return new EasyuiGridData(customerOrdeCreateSer.findAllRoute(),"id,startPort,destPort,baseShipRouteName,endCity,startCity");
    }

    @Override
    @Action
    @Order(2)
    @Label("查询航线报价列表")
    public EasyuiGridData findAllRoutePrice(ForwardPriceVo vo, int rows, int page) {
        return new EasyuiGridData(customerOrdeCreateSer.findAllRoutePrice(vo,rows,page),
                "id,containerNull,expiresEnd,baseCompany.companyName forwardName,gp20,gp40,hc40,maxNum,tk40");
    }

    @Override
    @Action
    @Order(2)
    @Label("查询码头列表")
    public EasyuiGridData findAllDockByPortName(String portName) {
        return new EasyuiGridData(customerOrdeCreateSer.findAllDockByPortName(portName),
                "id,name,portName");
    }

    @Override
    @Action
    @Order(2)
    @Label("查询区域列表")
    public EasyuiGridData findAllPlace(String cityName) {
        return new EasyuiGridData(customerOrdeCreateSer.findAllPlace(cityName),
                "id,name");
    }

    @Override
    @Action
    @Order(2)
    @Label("查询区域报价列表")
    public EasyuiGridData findAllPlacePrice(FleetPriceVo vo, int rows, int page) {
        return new EasyuiGridData(customerOrdeCreateSer.findAllPlacePrice(vo,  rows,  page),
                "id,gp20,baseCompany.companyName fleetName,baseDock.name dockName,basePlace.name placeName," +
                        "gp40,hc40,tk40,containerNull");
    }


}
